Daily Dashboard

This dashboard has been created according to worldometers.info design. In order to compensate with the lack of real time statistical data in Egypt, the given data below will be updated daily at 10:00 PM (Cairo Time).
Stay Home, Stay Safe.

Row

Total Coronavirus Cases in Egypt

32612

Total Coronavirus Deaths in Egypt

1209

Total Coronavirus Recovered Cases in Egypt

8158

Cases which had an outcome
Deaths/Discharged : 1209 (12.9%)
Recovered/Discharged : 8158 (87.1%)

Closed Cases: 9367

Currently Infected Patients

Active Cases: 23245

Row

Distibution of Cases

Row

Confirmed Cases per day

Deaths per day

Recovered Cases per day

Row

Total Confirmed Cases

Total Deaths

Total Recovered

Row

Number of closed cases per day

Rate of death after first 2 weeks

Weekly Dashboard

Row

Chart 1

Row

Weekly Distribution of New Confirmed Cases

Weekly Distribution of New Deaths

Weekly Distribution of New Recovered Cases


  1. https://github.com/Sherif-Embarak/

---
title: "Covid-19 in Egypt"
date:  "Last update: `r Sys.time()`"
author: Sherif Embarak^[https://github.com/Sherif-Embarak/]
output:
  flexdashboard::flex_dashboard:
    social: menu
    source: embed
    vertical_layout: scroll
    orientation: rows
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
rm(list=ls(all=TRUE))
options(stringsAsFactors = FALSE)
library(ggplot2)
library(plotly)
library(flexdashboard)
library(DT)
library(plotly)
library(knitr)
library(lubridate)
library(crosstalk)
library(scales)

setwd("D:/work/git corona/")
df <- read.csv("eg_covid.csv")
df$Day <- mdy(df$Day)
df$AccDay <- df$Day
df$Day <- paste(day(df$Day) , months.Date(df$Day) )
df$Curfew <- as.character(df$Curfew)
df$index <- as.numeric(rownames(df))
########################################################################
#weekly summary
AllDF <- df
shift <- 4
summary_AllDF <- data.frame(AllDF %>% mutate(week = ((as.numeric(AccDay)+shift) %/% 7) - ((as.numeric(min(AccDay))+shift) %/% 7)) %>% 
  group_by(week) %>%
  summarise(number_of_days= table(week), from = min(AccDay) , to = max(AccDay), sum(New.Cases) , sum(New.Deaths), sum(New.Recovered)))
summary_AllDF$number_of_days <- as.integer(summary_AllDF$number_of_days)
########################################################################
df <- df[,c(1:8,12)]
attach(df)
next_day <- max(index)+1
nd_new_case <-as.integer(exp(predict(glm(Total.Cases~index ,family = gaussian(link = 'log') ),list(index=c(next_day)))))
nd_new_deaths <-as.integer(exp(predict(glm(Total.Deaths~index ,family = gaussian(link = 'log') ),list(index=c(next_day)))))
nd_new_recoverd <-as.integer(exp(predict(glm(Total.Recovered~index ,family = gaussian(link = 'log') ),list(index=c(next_day)))))
total_cases <- df$Total.Cases[nrow(df)]
total_deaths <- df$Total.Deaths[nrow(df)]
total_recovered <- df$Total.Recovered[nrow(df)]
closed <- total_deaths+total_recovered
closed_curve <- AllDF$New.Deaths + AllDF$New.Recovered
active <- total_cases - closed
df$Day <- factor(df$Day, levels = df$Day)
xlabel <- df$Day[as.integer(seq(1 , nrow(df) , length.out = 10))]
rate_of_death <- (AllDF$Total.Deaths / (AllDF$Total.Deaths+AllDF$Total.Recovered))*100
rate_of_death <- round(rate_of_death , 2)


hk <- highlight_key(df, ~Total.Cases)

chart1 <-ggplotly(ggplot(hk, aes(x=Day, y=New.Cases)) + scale_x_discrete(breaks = xlabel)+
  geom_bar(width = 0.3, stat = "identity")+scale_fill_manual(values = c("#6698FF", "#153E7E"))+
  theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
    geom_text(label=paste("Tomorrow's predication:",nd_new_case - AllDF$Total.Cases[nrow(AllDF)] ), 
    x=10,
    y=max(New.Cases)
  )
  ,tooltip = c("x", "y")) %>%
       highlight(off = "plotly_relayout")

chart2 <-ggplotly(ggplot(hk, aes(x=Day, y=New.Deaths)) + scale_x_discrete(breaks = xlabel)+
  geom_bar(width = 0.3, stat = "identity")+scale_fill_manual(values = c("#6698FF", "#153E7E"))+
  theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
    geom_text(label=paste("Tomorrow's predication:",nd_new_deaths - AllDF$Total.Deaths[nrow(AllDF)]), 
    x=10,
    y=max(New.Deaths)
  )
  ,tooltip = c("x", "y")) %>%
       highlight(off = "plotly_relayout")

chart3 <-ggplotly(ggplot(hk, aes(x=Day, y=New.Recovered)) + scale_x_discrete(breaks = xlabel)+
  geom_bar(width = 0.3, stat = "identity")+scale_fill_manual(values = c("#6698FF", "#153E7E"))+
  theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
    geom_text(label=paste("Tomorrow's predication:",nd_new_recoverd - AllDF$Total.Recovered[nrow(AllDF)]), 
    x=10,
    y=max(New.Recovered)
  )
  ,tooltip = c("x", "y")) %>%
       highlight(off = "plotly_relayout")

chart4 <- ggplotly(ggplot(data=hk, aes(x=Day, y=Total.Cases, group=1))+ scale_x_discrete(breaks = xlabel)+
 geom_line(color="#33CCFF", size=1)+theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
    geom_smooth(aes(x=index, y=Total.Cases), method = "glm", formula = y~x,method.args = list(family = gaussian(link = 'log')))+
  geom_point(color="#33CCFF"),tooltip = c("x", "y")) %>%
       highlight(off = "plotly_relayout")

chart5 <- ggplotly(ggplot(data=hk, aes(x=Day, y=Total.Deaths, group=1))+ scale_x_discrete(breaks = xlabel)+
 geom_line(color="#FF9900", size=1)+theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
    geom_smooth(aes(x=index, y=Total.Deaths), method = "glm", formula = y~x,method.args = list(family = gaussian(link = 'log')))+
  geom_point(color="#FF9900"),tooltip = c("x", "y")) %>%
       highlight(off = "plotly_relayout")

chart6 <- ggplotly(ggplot(data=hk, aes(x=Day, y=Total.Recovered, group=1))+ scale_x_discrete(breaks = xlabel)+
 geom_line(color="#00DDDD", size=1)+theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
    geom_smooth(data = hk, aes(x=index, y=Total.Recovered), method = "glm", formula = y~x,method.args = list(family = gaussian(link = 'log')))+
  geom_point(color="#00DDDD"),tooltip = c("x", "y"))%>%
       highlight(off = "plotly_relayout")

chart10 <- ggplotly(ggplot(data=hk, aes(x=Day, y=closed_curve, group=1))+ scale_x_discrete(breaks = xlabel)+
 geom_line(color="#00DDDD", size=1)+theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
  geom_point(color="#00DDDD"),tooltip = c("x", "y"))%>%
       highlight(off = "plotly_relayout")

hk2 <- highlight_key(df[15:nrow(df),], ~Total.Cases)
rate_of_death <- rate_of_death[15:nrow(df)]

chart11 <- ggplotly(ggplot(data=hk2, aes(x=Day, y=rate_of_death, group=1))+ 
                      ylab("Rate of Death (%)") +scale_x_discrete(breaks = xlabel)+
 geom_line(color="#00DDDD", size=1)+theme(panel.grid.major.x  = element_blank(), axis.text.x = element_text(angle = 70, hjust = 1))+
  geom_point(color="#00DDDD"),tooltip = c("x", "y"))%>%
       highlight(off = "plotly_relayout")


```

Daily Dashboard
=======================================================================
This dashboard has been created according to  worldometers.info  design. In order to compensate with the lack of real time statistical data in Egypt, the given data below will be updated daily at 10:00 PM (Cairo Time).
Stay Home, Stay Safe.

Row ----------------------------------------------------------------------- ### Total Coronavirus Cases in Egypt ```{r, echo=FALSE} valueBox(total_cases) ``` ### Total Coronavirus Deaths in Egypt ```{r, echo=FALSE} valueBox(total_deaths, color="warning") ``` ### Total Coronavirus Recovered Cases in Egypt ```{r, echo=FALSE} valueBox(total_recovered , color = "#00DDDD") ``` ### Cases which had an outcome `r "
"` `r paste0("Deaths/Discharged : ", total_deaths, " (", round((total_deaths/closed)*100,1),"%)" )` `r "
"` `r paste0("Recovered/Discharged : ", total_recovered, " (", round((total_recovered/closed)*100,1),"%)" )` ```{r, echo=FALSE} valueBox(paste("Closed Cases: ",closed)) ``` ### Currently Infected Patients ```{r, echo=FALSE} valueBox(paste("Active Cases: ",active)) ``` Row ------------------------------------- ### Distibution of Cases ```{r, echo=FALSE } DT::datatable(hk,class = 'cell-border stripe hover compact', rownames = FALSE , options = list(pageLength = 1,order = list(2, 'desc')))%>% formatStyle('New.Cases', backgroundColor = '#FFEEAA') %>% formatStyle('New.Deaths',backgroundColor = 'red')%>% formatStyle(names(df),fontWeight = 'bold')%>% formatStyle('Curfew', backgroundColor = styleEqual(c(0, 1), c('#a6cee3', '#1f78b4')))%>% highlight(on = "plotly_click" , off ="plotly_doubleclick") ``` Row ------------------------------------- ### Confirmed Cases per day ```{r, echo=FALSE ,fig.height=3} chart1 ``` ### Deaths per day ```{r, echo=FALSE ,fig.height=3} chart2 ``` ### Recovered Cases per day ```{r, echo=FALSE ,fig.height=3} chart3 ``` Row ------------------------------------- ### Total Confirmed Cases ```{r, echo=FALSE, warning=FALSE,message=FALSE,results='asis',fig.show='asis'} chart4 ``` ### Total Deaths ```{r, echo=FALSE, warning=FALSE,message=FALSE,results='asis',fig.show='asis'} chart5 ``` ### Total Recovered ```{r, echo=FALSE, warning=FALSE,message=FALSE,results='asis',fig.show='asis'} chart6 ``` Row ------------------------------------- ### Number of closed cases per day ```{r, echo=FALSE, warning=FALSE,message=FALSE,results='asis',fig.show='asis'} chart10 ``` ### Rate of death after first 2 weeks ```{r, echo=FALSE, warning=FALSE,message=FALSE,results='asis',fig.show='asis'} chart11 ``` Weekly Dashboard ======================================================================= ```{r, include=FALSE} summary_AllDF$week <- as.factor(summary_AllDF$week) weekly_hk <- highlight_key(summary_AllDF, ~week) chart7 <- ggplotly(ggplot(weekly_hk, aes(x=week , y=sum.New.Cases. , text =paste("from:", from, "to:",to))) + geom_bar(width = 0.4 , stat = "identity" , fill="steelblue")+ geom_text(aes(label=sum.New.Cases.), color="black", size=3.5)+ theme(panel.grid.major.x = element_blank()),tooltip = c("x", "y" , "text")) %>% highlight(off = "plotly_relayout") chart8 <-ggplotly(ggplot(weekly_hk, aes(x=week , y=sum.New.Deaths. , text =paste("from:", from, "to:",to))) + geom_bar(width = 0.4 , stat = "identity", fill="steelblue")+ geom_text(aes(label=sum.New.Deaths.), color="black", size=3.5)+ theme(panel.grid.major.x = element_blank()),tooltip = c("x", "y" , "text")) %>% highlight(off = "plotly_relayout") chart9 <-ggplotly(ggplot(weekly_hk, aes(x=week , y=sum.New.Recovered. , text =paste("from:", from, "to:",to))) + geom_bar(width = 0.4 , stat = "identity", fill="steelblue")+ geom_text(aes(label=sum.New.Recovered.), color="black", size=3.5)+ theme(panel.grid.major.x = element_blank()),tooltip = c("x", "y" , "text")) %>% highlight(off = "plotly_relayout") plot(x = AllDF$AccDay[15:length(rate_of_death)], y = rate_of_death[15:length(rate_of_death)],xlab = "Day" , ylab = "Rate of death" , ylim = c(10,30) ) lines(x = AllDF$AccDay[15:length(rate_of_death)], y = rate_of_death[15:length(rate_of_death)] ) ``` Row ------------------------------------- ### Chart 1 ```{r, echo=FALSE , fig.height = 2, fig.width = 2} DT::datatable(weekly_hk)%>% highlight(on = "plotly_click" , off ="plotly_doubleclick") ``` Row ------------------------------------- ### Weekly Distribution of New Confirmed Cases ```{r, echo=FALSE} chart7 ``` ### Weekly Distribution of New Deaths ```{r, echo=FALSE} chart8 ``` ### Weekly Distribution of New Recovered Cases ```{r, echo=FALSE} chart9 ```